import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import AppLayout from '@/layout/AppLayout.vue'
import productRouter from './modules/product'
import settingRouter from './modules/setting'
import systemRouter from './modules/system'
import orderRouter from './modules/order'
import mediaRouter from './modules/media'
import iframeRouter from './modules/iframe'
import configRouter from './modules/config'

import '../public-path'
const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: AppLayout,
    children: [
      {
        path: '', // 默认子路由
        name: 'home',
        component: () => import('../views/home/index.vue'),
        meta: { title: '首页', requiresAuth: true }
      },
      productRouter,
      settingRouter,
      systemRouter,
      orderRouter,
      mediaRouter,
      iframeRouter,
      configRouter,
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/index.vue')
  }
]

// const router = createRouter({
//   base: window.__POWERED_BY_QIANKUN__ ? '/vue' : '/', // 重点4：qiankun进入子应用时，返回true
//   history: createWebHashHistory(), // 路由模式
//   routes // 路由规则
// })
const router = createRouter({
  base: window.__POWERED_BY_QIANKUN__ ? "/app-vue" : "/",
  // base: '/vue-child',//此处就是我们之前定义的微应用的入口路由
  history: createWebHashHistory('/app-vue'),
  routes
  // history: createWebHashHistory('/child-one'),
})

// 全局前置守卫
router.beforeEach((to, form) => {
})

// 全局后置守卫
router.afterEach(() => {
})

export default router
